<?php
/**
 * Created By Project
 * Author: 陈东
 * Copyright：陈东
 * Source Code：陈东
 * Explain：I shall not authorize for any other commercial purposes, law breakers must be prosecuted.
 */
namespace Admin\Controller;
use Think\Controller;

class SelfehelpController extends BaseController {

    public function index(){
		$selefres = D(C('TABLE_SELFHELPRESOURCE'));
		$count = $selefres->count();
		//每页显示条数
		$num = 12;
		$page = new \Think\Page($count,$num);
		$obj = pagestyle($page);
		$show = $obj->show();
		$res = $selefres->order(array('id'=>'DESC'))->limit($obj->firstRow.','.$obj->listRows)->select();
		$this->assign('list',$res);
		$this->assign('page',$show);
    	$this->display();
    }
	//删除或恢复
	public function operation(){
		$id = I('get.id');
		$s = I('get.s');
		$selefres = D(C('TABLE_SELFHELPRESOURCE'));
		if($s==1){
			$selefres->status = 0;
		}else if($s==0){
			$selefres->status = 1;
		}else if($s==2){
			$selefres->status = 2;
		}else if($s==3){
			$selefres->status = 1;
		}else if($s==4){
			$selefres->status = 3;
		}
		$res = $selefres->where(array('id'=>$id))->save();
		if($res || $res==0){
			header('Location:'.U('index'));
		}else{
			$this->error('操作失败！',U('index'),1);
		}
	}



}